package com.uzai.console.web.sys;

import com.alibaba.excel.util.StringUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.sys.copyconfigplan.CopyConfigPlanSaveDto;
import com.uzai.console.dto.sys.copyconfigplan.CopyPrivateConfigPlanDto;
import com.uzai.console.dto.sys.shortlink.ShortLinkDto;
import com.uzai.console.dto.wechatprivate.configplan.ConfigPlanCopyDefaultDto;
import com.uzai.console.dto.wechatprivate.configplan.ConfigPlanQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.configplan.ConfigPlanService;
import com.uzai.console.service.sys.CopyConfigPlanService;
import com.uzai.console.service.sys.ShortLinkService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.sys.shortlink.ShortLinkVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liuqi
 * @date 2021年09月11日 20:15
 */
@Api(value = "复制配置",tags = "系统设置")
@ApiSort(30)
@RestController
public class CopyConfigPlanController extends BaseController {

    @Autowired
    private CopyConfigPlanService copyConfigPlanService;
    @Autowired
    private ConfigPlanService configPlanService;

    @SystemLogType(model = SystemModelEnum.ShortLink, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "复制他人配置方案", notes = "复制他人配置方案")
    @ApiOperationSupport(order = 1)
    @PostMapping("/copyConfigPlan/saveCopyConfigPlan")
    public Object saveCopyConfigPlan(@RequestBody CopyConfigPlanSaveDto copyConfigPlanSaveDto){
        copyConfigPlanService.saveCopyConfigPlan(copyConfigPlanSaveDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.ShortLink, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "复制自己的配置方案", notes = "复制自己的配置方案")
    @ApiOperationSupport(order = 2)
    @PostMapping("/copyConfigPlan/copyPrivateConfigPlan")
    public Object copyPrivateConfigPlan(@RequestBody CopyPrivateConfigPlanDto copyPrivateConfigPlanDto){
        copyConfigPlanService.copyPrivateConfigPlan(copyPrivateConfigPlanDto);
        return true;
    }

    @ApiOperation(value = "查询设备类型下拉列表（复制自己配置方案）", notes = "查询复制设备类型下拉列表（复制自己配置方案）", response = SelectKeyVo.class)
    @ApiOperationSupport(order=3)
    @PostMapping("/copyConfigPlan/findDeviceTypeListSelect")
    public Object findDeviceTypeListSelect(){
        List<SelectKeyVo> selectKeyVoList = new ArrayList<>();
        SelectKeyVo selectKeyVo_wechat = new SelectKeyVo();
        selectKeyVo_wechat.setKey(DeviceTypeEnum.DT_PC_WECHAT.getKey());
        selectKeyVo_wechat.setValue("个人微信");
        selectKeyVoList.add(selectKeyVo_wechat);

        SelectKeyVo selectKeyVo_wxwork = new SelectKeyVo();
        selectKeyVo_wxwork.setKey(DeviceTypeEnum.DT_WORK_WECHAT.getKey());
        selectKeyVo_wxwork.setValue("企业微信");
        selectKeyVoList.add(selectKeyVo_wxwork);

        SelectKeyVo selectKeyVo_wxpub = new SelectKeyVo();
        selectKeyVo_wxpub.setKey(DeviceTypeEnum.DT_WORK_WECHAT.getKey());
        selectKeyVo_wxpub.setValue("公众号");
        selectKeyVoList.add(selectKeyVo_wxpub);
        return selectKeyVoList;
    }

    @ApiOperation(value = "查询配置方案下拉列表（复制自己配置方案）", notes = "查询复制设备类型下拉列表（复制自己配置方案）", response = SelectKeyVo.class)
    @ApiOperationSupport(order=4)
    @PostMapping("/copyConfigPlan/findConfigPlanSelectList")
    public Object findConfigPlanSelectList(@RequestBody ConfigPlanQuery query){
        return  copyConfigPlanService.findConfigPlanSelectList(query);
    }

}
